package com.fenghongzhang.day007;

import android.content.Intent;
import android.os.Bundle;
import android.widget.RadioButton;
import android.widget.RadioGroup;

import androidx.appcompat.app.AppCompatActivity;

public class InfoActivity extends AppCompatActivity {
    private RadioGroup group;
    private RadioButton ku;
    private RadioButton se;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_info);



        group = (RadioGroup) findViewById(R.id.group);
        ku = (RadioButton) findViewById(R.id.ku);
        se = (RadioButton) findViewById(R.id.se);

        //2.选择事件
        group.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(RadioGroup group, int checkedId) {
                int i = 0;
                //在这里根据选中的id. 需要图片的id.返回回去就行.
                switch (checkedId){
                    case R.id.ku:
                        i = R.mipmap.ku;
                        break;
                    case R.id.se:
                        i = R.mipmap.se;
                        break;
                }


                Intent intent = new Intent();
                intent.putExtra("imgId",i);
                //4. 返回值
                setResult(101,intent);

                //5.关闭当前页面
                finish();
            }

        });


    }
}
